﻿using System;
using System.Data;
using System.Collections.Generic;
using Chenxin.Lib.Passport.Entity;
using System.Collections;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Data.Common;
using Chenxin.Lib.Utility;


namespace Chenxin.Lib.Passport.BLL
{
    /// <summary>
    /// 业务逻辑类Hr_UserInfo 的摘要说明。
    /// </summary>
    public class Hr_UserInfo
    {
        public Hr_UserInfo()
        { }

        #region  成员方法

        //Cache服务类
        private Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.HR);

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(Guid UserId)
        {
            return Chenxin.Lib.Passport.DAL.Hr_UserInfo.Exists(UserId);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public string Add(Chenxin.Lib.Passport.Entity.Hr_UserInfo model)
        {
            //Chenxin.Lib.Hr.Entity.Struct_UserDepartRelation entUserDepart = new Chenxin.Lib.Hr.Entity.Struct_UserDepartRelation();

            //entUserDepart.DepartId = model.DepartId;
            //entUserDepart.DepartName = model.DepartName;
            //entUserDepart.UserId = model.UserId;
            //entUserDepart.UserName = model.UserName;
            //entUserDepart.IsBelong = true;
            //entUserDepart.RecordId = Guid.NewGuid();

            //Chenxin.Lib.Hr.DAL.Struct_UserDepartRelation.Add(entUserDepart);

            Chenxin.Lib.Passport.DAL.Hr_UserInfo.Add(model);

            string setting = UserSetting(model.UserId.ToString(), 1, "", "", DateTime.Now, "", Guid.Empty, "", "", "");
            string strKDepUsers = string.Format(Chenxin.Lib.Cache.CacheDataType.HR_DEPARTMENT_USERS, model.DepartId + ".0");
            cs.Delete(strKDepUsers);
            strKDepUsers = string.Format(Chenxin.Lib.Cache.CacheDataType.HR_DEPARTMENT_USERS, model.DepartId + ".1");
            cs.Delete(strKDepUsers);
            return setting;
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Chenxin.Lib.Passport.Entity.Hr_UserInfo model)
        {
            //用户信息键
            string strGKeyUser = string.Format(Chenxin.Lib.Cache.CacheDataType.USER, model.UserId.ToString());
            string strGUser = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_USER, model.UserId.ToString());
            //部门下用户的缓存
            string strKDepUsers = string.Format(Chenxin.Lib.Cache.CacheDataType.HR_DEPARTMENT_USERS, model.DepartId + ".0");
            cs.Delete(strKDepUsers);
            strKDepUsers = string.Format(Chenxin.Lib.Cache.CacheDataType.HR_DEPARTMENT_USERS, model.DepartId + ".1");
            cs.Delete(strKDepUsers);
            //删除部门下用户的缓存
            cs.Delete(strGKeyUser);
            cs.Delete(strGUser);
            cs.Delete(strKDepUsers);
            Chenxin.Lib.Passport.DAL.Hr_UserInfo.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(Guid UserId)
        {
            //用户信息键
            string strGKeyUser = string.Format(Chenxin.Lib.Cache.CacheDataType.USER, UserId.ToString());
            string strGUser = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_USER, UserId.ToString());
            Chenxin.Lib.Passport.Entity.Hr_UserInfo model = GetEntityById(UserId);
            string strKDepUsers = string.Format(Chenxin.Lib.Cache.CacheDataType.HR_DEPARTMENT_USERS, model.DepartId + ".0");
            cs.Delete(strKDepUsers);
            strKDepUsers = string.Format(Chenxin.Lib.Cache.CacheDataType.HR_DEPARTMENT_USERS, model.DepartId + ".1");
            cs.Delete(strKDepUsers);
            strKDepUsers = string.Format(Chenxin.Lib.Cache.CacheDataType.HR_DEPARTMENT_USERS, model.DepartId + ".-1");
            cs.Delete(strKDepUsers);
            Chenxin.Lib.Passport.DAL.Hr_UserInfo.Delete(UserId);
            cs.Delete(strGKeyUser);
            cs.Delete(strGUser);
        }

        /// <summary>
        /// 通过UserId得到一个对象实体
        /// </summary>
        public Chenxin.Lib.Passport.Entity.Hr_UserInfo GetEntityById(Guid UserId)
        {
            string strKeyUser = string.Format(Chenxin.Lib.Cache.CacheDataType.USER, UserId.ToString());

            Chenxin.Lib.Passport.Entity.Hr_UserInfo entHrUserInfo;

            entHrUserInfo = cs.GetObject<Chenxin.Lib.Passport.Entity.Hr_UserInfo>(strKeyUser);

            if (!cs.Hit)
            {
                entHrUserInfo = Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetEntityById(UserId);
                if (entHrUserInfo != null) cs.Set(strKeyUser, entHrUserInfo);
            }

            return entHrUserInfo;
        }

        /// <summary>
        /// 通过UserCode得到一个对象实体
        /// </summary>
        public Chenxin.Lib.Passport.Entity.Hr_UserInfo GetEntityByCode(string UserCode)
        {

            return Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetEntityByCode(UserCode);
        }

        /// <summary>
        /// 验证变动时间 (type=1:根据userid查询，type=2:根据recordid查询)
        /// </summary>
        public static bool CheckTime(string userid, DateTime changeTime, int type)
        {
            string strSql = "";
            if (type == 1)
                strSql = string.Format("select count(*) from Hr_PersonnelTransferInfo where UserId='{0}' and TransTime>='{1}'", userid, changeTime);
            else if (type == 2)
                strSql = string.Format("select count(*) from Hr_Struct_UserDepartRelation where RecordId='{0}' and ComeDate<'{1}'", userid, changeTime);
            bool flag = Chenxin.Lib.Hr.DAL.Struct_UserDepartRelation.SearchSQL(strSql);
            return flag;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetList(strWhere);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.Passport.Entity.Hr_UserInfo> GetModelList(string strWhere)
        {
            DataSet ds = Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }


        /// <summary>
        /// 员工相关关系设定
        /// </summary>
        public static string UserSetting(string Userid, int type, string TransType, string TransReason, DateTime TransTime, string AddPerson, Guid DepartId, string DepartName, string Position, string Level)
        {

            Database db = DatabaseFactory.CreateDatabase("Chenxin_Main");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_Hr_UserSetting");

            db.AddInParameter(dbCommand, "UserId", DbType.AnsiString, Userid);
            db.AddInParameter(dbCommand, "OperateType", DbType.Int32, type);
            db.AddInParameter(dbCommand, "TransType", DbType.AnsiString, TransType);
            db.AddInParameter(dbCommand, "TransReason", DbType.AnsiString, TransReason);
            db.AddInParameter(dbCommand, "TransTime", DbType.DateTime, TransTime);
            db.AddInParameter(dbCommand, "AddPerson", DbType.AnsiString, AddPerson);
            db.AddInParameter(dbCommand, "DepartId", DbType.Guid, DepartId);
            db.AddInParameter(dbCommand, "DepartName", DbType.AnsiString, DepartName);
            db.AddInParameter(dbCommand, "Position", DbType.AnsiString, Position);
            db.AddInParameter(dbCommand, "Level", DbType.AnsiString, Level);
            db.AddOutParameter(dbCommand, "HasHanderSetting", DbType.AnsiString, 10);
            db.ExecuteNonQuery(dbCommand);

            Chenxin.Lib.Cache.CacheService cs_hr = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.HR);
            //用户信息键
            string strGKeyUser = string.Format(Chenxin.Lib.Cache.CacheDataType.USER, Userid.ToString());
            string strGUser = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_USER, Userid.ToString());
            cs_hr.Delete(strGKeyUser);
            cs_hr.Delete(strGUser);
            return db.GetParameterValue(dbCommand, "HasHanderSetting").ToString();
        }

        /// <summary>
        /// 得到员工工号
        /// </summary>
        public static string GetUserCode(Guid Companyid, string CompanyCode)
        {
            Database db = DatabaseFactory.CreateDatabase("Chenxin_Main");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_AutoGenerateUserCode");

            //System.Data.SqlClient.SqlParameter 
            db.AddInParameter(dbCommand, "CompanyId", DbType.Guid, Companyid);
            db.AddInParameter(dbCommand, "Prefix", DbType.AnsiString, CompanyCode);
            db.AddOutParameter(dbCommand, "UserCode", DbType.AnsiString, 150);
            db.ExecuteNonQuery(dbCommand);

            return db.GetParameterValue(dbCommand, "UserCode").ToString();
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetUserList(Hashtable hsParams)
        {
            //where文
            System.Text.StringBuilder strWhere = new System.Text.StringBuilder();

            //当前页数
            int intCurPage = 1;
            //显示行数
            int intRowCnt = 10;

            strWhere.Append(" IsVirtual=0 ");
            strWhere.Append(" And Status = 1 ");
            strWhere.Append(" And Validate = 1 ");

            //权限
            string strPermit;

            //权限
            if (hsParams.ContainsKey("Permit"))
            {
                strPermit = hsParams["Permit"].ToString();
                if (strPermit == Constants.Permit_ViewAllAttendance)
                {
                    //全部
                }
                else if (strPermit == Constants.Permit_ViewCityAttendance)
                {
                    strWhere.AppendFormat(" And CityId = '{0}'", hsParams["CurCityId"]);
                }
                else if (strPermit == Constants.Permit_ViewCompanyAttendance)
                {
                    strWhere.AppendFormat(" And CompanyId= '{0}'", hsParams["CurCompanyId"]);
                }
                else if (strPermit == Constants.Permit_ViewDepartAttendance)
                {
                    strWhere.Append(" And EXISTS(");
                    strWhere.AppendFormat("Select 1 from Struct_UserDepartRelation M WHERE Hr_UserInfo.DepartId=M.DepartId And M.Userid= '{0}' And M.ViewAttendance=1 ", hsParams["CurUserId"]);
                    strWhere.Append(") ");
                }
            }
            //权限为当前用户
            else if (hsParams.ContainsKey("CurUserId"))
            {
                strWhere.Append(" And UserId = '" + hsParams["CurUserId"] + "'");
            }

            //用户名
            if (hsParams.ContainsKey("UserId"))
            {
                strWhere.Append(" And UserId = '" + hsParams["UserId"] + "'");
            }
            //部门
            else if (hsParams.ContainsKey("DepartId"))
            {
                strWhere.Append(" And DepartId = '" + hsParams["DepartId"] + "'");
            }
            //商圈
            else if (hsParams.ContainsKey("AreaId"))
            {
                Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo entArea = null;
                string strCachkey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_DEPARTMENT, hsParams["AreaId"]);
                cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);

                entArea = cs.GetObject<Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo>(strCachkey);
                if (!cs.Hit)
                {
                    entArea = Chenxin.Lib.Hr.DAL.Hr_DepartmentInfo.GetModel(new Guid(hsParams["AreaId"].ToString()));
                    if (entArea != null) cs.Set(strCachkey, entArea, DateTime.Now.AddDays(1));
                }

                if (entArea != null)
                {
                    //strWhere.AppendFormat(" AND (DepartId in (select departId from Hr_DepartmentInfo where DepartSrc like '{0}%'))", entArea.DepartSrc);

                    strWhere.Append(" And EXISTS(");
                    strWhere.AppendFormat("Select 1 from Hr_DepartmentInfo M WHERE Hr_UserInfo.DepartId=M.DepartId And  M.DepartSrc like '{0}%'", entArea.DepartSrc);
                    strWhere.Append(") ");
                }
            }
            //公司
            else if (hsParams.ContainsKey("CompanyId"))
            {
                strWhere.AppendFormat(" And CompanyId= '{0}'", hsParams["CompanyId"]);
            }
            //城市
            else if (hsParams.ContainsKey("CityId"))
            {
                strWhere.AppendFormat(" And CityId = '{0}'", hsParams["CityId"]);
            }

            //当前页数
            if (hsParams.ContainsKey("pageIndex"))
            {
                intCurPage = Convert.ToInt32(hsParams["pageIndex"]);
            }
            //显示行数
            if (hsParams.ContainsKey("pageSize"))
            {
                intRowCnt = Convert.ToInt32(hsParams["pageSize"]);
            }

            //table名
            string strTableNm = " Hr_UserInfo ";
            //order文
            string strOrder = "Hr_UserInfo.DepartId,Hr_UserInfo.UserCode";
            string FieldList = " UserId,UserName,UserCode,DepartId ";
            string TableFieldList = "UserId,UserName,UserCode,DepartId ";

            DataSet ds = Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetList(intCurPage, intRowCnt, strOrder, strTableNm, strWhere.ToString(), FieldList, TableFieldList, true);

            return ds;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.Passport.Entity.Hr_UserInfo> DataTableToList(DataTable dt)
        {
            List<Chenxin.Lib.Passport.Entity.Hr_UserInfo> modelList = new List<Chenxin.Lib.Passport.Entity.Hr_UserInfo>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Chenxin.Lib.Passport.Entity.Hr_UserInfo model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Chenxin.Lib.Passport.Entity.Hr_UserInfo();
                    if (dt.Rows[n]["UserId"].ToString() != "")
                    {
                        model.UserId = new Guid(dt.Rows[n]["UserId"].ToString());
                    }
                    model.UserCode = dt.Rows[n]["UserCode"].ToString();
                    if (dt.Rows[n]["CityId"].ToString() != "")
                    {
                        model.CityId = new Guid(dt.Rows[n]["CityId"].ToString());
                    }
                    model.CityName = dt.Rows[n]["CityName"].ToString();
                    if (dt.Rows[n]["CompanyId"].ToString() != "")
                    {
                        model.CompanyId = new Guid(dt.Rows[n]["CompanyId"].ToString());
                    }
                    model.CompanyName = dt.Rows[n]["CompanyName"].ToString();
                    if (dt.Rows[n]["Validate"].ToString() != "")
                    {
                        if ((dt.Rows[n]["Validate"].ToString() == "1") || (dt.Rows[n]["Validate"].ToString().ToLower() == "true"))
                        {
                            model.Validate = true;
                        }
                        else
                        {
                            model.Validate = false;
                        }
                    }
                    model.Password = dt.Rows[n]["Password"].ToString();
                    if (dt.Rows[n]["UserType"].ToString() != "")
                    {
                        model.UserType = int.Parse(dt.Rows[n]["UserType"].ToString());
                    }
                    model.UserName = dt.Rows[n]["UserName"].ToString();
                    if (dt.Rows[n]["Sex"].ToString() != "")
                    {
                        model.Sex = int.Parse(dt.Rows[n]["Sex"].ToString());
                    }
                    model.Education = dt.Rows[n]["Education"].ToString();
                    model.IDType = dt.Rows[n]["IDType"].ToString();
                    model.IDNo = dt.Rows[n]["IDNo"].ToString();
                    if (dt.Rows[n]["BirthDay"].ToString() != "")
                    {
                        model.BirthDay = DateTime.Parse(dt.Rows[n]["BirthDay"].ToString());
                    }
                    model.Address = dt.Rows[n]["Address"].ToString();
                    model.Mobile = dt.Rows[n]["Mobile"].ToString();
                    model.HomeTel = dt.Rows[n]["HomeTel"].ToString();
                    model.OfficeTel = dt.Rows[n]["OfficeTel"].ToString();
                    model.BankNo = dt.Rows[n]["BankNo"].ToString();
                    if (dt.Rows[n]["ConBegin"].ToString() != "")
                    {
                        model.ConBegin = DateTime.Parse(dt.Rows[n]["ConBegin"].ToString());
                    }
                    if (dt.Rows[n]["ConEnd"].ToString() != "")
                    {
                        model.ConEnd = DateTime.Parse(dt.Rows[n]["ConEnd"].ToString());
                    }
                    if (dt.Rows[n]["DepartId"].ToString() != "")
                    {
                        model.DepartId = new Guid(dt.Rows[n]["DepartId"].ToString());
                    }
                    model.DepartName = dt.Rows[n]["DepartName"].ToString();
                    if (dt.Rows[n]["Position"].ToString() != "")
                    {
                        model.Position = dt.Rows[n]["Position"].ToString();
                    }
                    if (dt.Rows[n]["EmpLevel"].ToString() != "")
                    {
                        model.EmpLevel = dt.Rows[n]["EmpLevel"].ToString();
                    }
                    if (dt.Rows[n]["ComeDate"].ToString() != "")
                    {
                        model.ComeDate = DateTime.Parse(dt.Rows[n]["ComeDate"].ToString());
                    }
                    model.FundCode = dt.Rows[n]["FundCode"].ToString();
                    if (dt.Rows[n]["PassUpdateTime"].ToString() != "")
                    {
                        model.PassUpdateTime = DateTime.Parse(dt.Rows[n]["PassUpdateTime"].ToString());
                    }
                    model.Remark = dt.Rows[n]["Remark"].ToString();
                    if (dt.Rows[n]["AddTime"].ToString() != "")
                    {
                        model.AddTime = DateTime.Parse(dt.Rows[n]["AddTime"].ToString());
                    }
                    if (dt.Rows[n]["UpdateTime"].ToString() != "")
                    {
                        model.UpdateTime = DateTime.Parse(dt.Rows[n]["UpdateTime"].ToString());
                    }
                    model.AddPerson = dt.Rows[n]["AddPerson"].ToString();
                    model.AddDepart = dt.Rows[n]["AddDepart"].ToString();
                    if (dt.Rows[n]["Status"].ToString() != "")
                    {
                        model.Status = int.Parse(dt.Rows[n]["Status"].ToString());
                    }
                    if (dt.Rows[n]["NeedChgPass"].ToString() != "")
                    {
                        if ((dt.Rows[n]["NeedChgPass"].ToString() == "1") || (dt.Rows[n]["NeedChgPass"].ToString().ToLower() == "true"))
                        {
                            model.NeedChgPass = true;
                        }
                        else
                        {
                            model.NeedChgPass = false;
                        }
                    }
                    //Add by tianno 2010-04-07
                    if (dt.Rows[n]["IsVirtual"].ToString() != "")
                    {
                        if ((dt.Rows[n]["IsVirtual"].ToString() == "1") || (dt.Rows[n]["IsVirtual"].ToString().ToLower() == "true"))
                        {
                            model.IsVirtual = true;
                        }
                        else
                        {
                            model.IsVirtual = false;
                        }
                    }
                    //Add by tianno 2010-07-21
                    model.Zip = dt.Rows[n]["Zip"].ToString();
                    model.WorkRelation = dt.Rows[n]["WorkRelation"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        public string ExportData(System.Collections.Hashtable hsParams)
        {
            //order文
            string strOrder = "Hr_UserInfo.UserCode desc";
            if (hsParams.ContainsKey("sort"))
            {
                strOrder = "Hr_UserInfo." + hsParams["sort"].ToString();
            }
            //where文
            string strWhere = getWhere(hsParams);
            string TableFieldList = "UserId,UserCode, UserName,BelongDepart,dbo.FN_GetBussinessByDepartID(BelongDepartId) as BelongBusiness,BelongCompanyName,BelongCityName,Position, EmpLevel,DepartName,dbo.FN_GetBussinessByDepartID(DepartId) as Business,CompanyName,CityName,convert(char,ComeDate,23) AS ComeDate,CASE WHEN Sex='0' THEN '男' ELSE '女' END  AS Sex,Education,IDNo,CASE WHEN BirthDay IS NULL THEN '' ELSE convert(char,BirthDay,23) END AS BirthDay,DateDiff(year, BirthDay ,getdate()) AS Age,Address,zip,Mobile,HomeTel,OfficeTel,FundCode,convert(char,ConBegin,23) AS ConBegin,convert(char,ConEnd,23) AS ConEnd,CASE WHEN LeaveDate IS NULL THEN '' ELSE convert(char,LeaveDate,23) END AS LeaveDate,dbo.FN_GetStrRoles(UserId) AS RoleName,convert(char,UpdateTime,23) AS UpdateTime,convert(char,AddTime,23) AS AddTime,Status,Validate,WorkRelation";
            string strSql = "select " + TableFieldList + " from Hr_UserInfo where " + strWhere + " order by " + strOrder;
            DataSet ds = Chenxin.Lib.Passport.DAL.Hr_UserInfo.ExecuteSql(strSql);
            string strhtml = GetHTMLData(ds.Tables[0],hsParams["show"].ToString());
            return strhtml;
        }

        private string GetHTMLData(DataTable dt,string type)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            sb.Append("<table><tr>");
            sb.Append("<td>员工编号</td>");
            sb.Append("<td>员工姓名</td>");
            sb.Append("<td>状态</td>");
            sb.Append("<td>所属部门</td>");
            if (type != "2"&&type!="1")
                sb.Append("<td>所属商圈</td>");
            sb.Append("<td>所属公司</td>");
            if (type != "2"&&type!="1")
                sb.Append("<td>所属城市</td>");
            if(type!="2")
                sb.Append("<td>职务</td>");
            if (type != "2" && type != "1")            
                sb.Append("<td>职级</td>");
            if (type != "2" && type != "1")
                sb.Append("<td>业务部门</td>");
            if (type != "2" && type != "1")
                sb.Append("<td>业务商圈</td>");
            if (type != "2" && type != "1")
                sb.Append("<td>业务公司</td>");
            if (type != "2" && type != "1")
                sb.Append("<td>业务城市</td>");
            sb.Append("<td>入职时间</td>");
            sb.Append("<td>性别</td>");
            sb.Append("<td>学历</td>");
            sb.Append("<td>证件号</td>");
            if( type != "1")
                sb.Append("<td>生日日期</td>");
            if(type != "1")
                sb.Append("<td>年龄</td>");
            if (type != "2")
                sb.Append("<td>联系地址</td>");
            if (type != "2" && type != "1")
                sb.Append("<td>邮编</td>");
            sb.Append("<td>手机</td>");
            if (type != "2")
                sb.Append("<td>家庭电话</td>");
            if (type != "2")
                sb.Append("<td>办公电话</td>");
            if (type != "2" && type != "1")
                sb.Append("<td>公积金账号</td>");
            if (type != "2")
                sb.Append("<td>合同起始</td>");
            if (type != "2")
                sb.Append("<td>合同终止</td>");
            if (type != "2")
                sb.Append("<td>离职日期</td>");
            if (type != "2" && type != "1")
                sb.Append("<td>角色名</td>");
            if (type != "2" && type != "1")
                sb.Append("<td>更新日期</td>");
            if (type != "2" && type != "1")
                sb.Append("<td>建档日期</td>");
            sb.Append("<td>劳动关系</td></tr>");

            foreach (System.Data.DataRow row in dt.Rows)
            {                
                sb.AppendFormat("<tr><td name=\"UserCode\" title=\"{0}\">{0}</td>", row["UserCode"].ToString());
                sb.AppendFormat("<td name=\"UserName\" title=\"{0}\">{0}</td>", row["UserName"].ToString());
                sb.AppendFormat("<td name=\"Status\" style=\"display:none;\">{0}</td>", row["Status"].ToString() == "1" ? "在职" : "离职");
                sb.AppendFormat("<td name=\"DepartName\" title=\"{0}\">{0}</td>", row["BelongDepart"].ToString());
                if (type != "2" && type != "1")
                sb.AppendFormat("<td name=\"BelongBusiness\" title=\"{0}\">{0}</td>", row["BelongBusiness"].ToString());
                sb.AppendFormat("<td name=\"BelongCompanyName\" title=\"{0}\">{0}</td>", row["BelongCompanyName"].ToString());
                if (type != "2" && type != "1")
                sb.AppendFormat("<td name=\"BelongCityName\" title=\"{0}\">{0}</td>", row["BelongCityName"].ToString());
                if (type != "2")
                sb.AppendFormat("<td name=\"Position\" title=\"{0}\">{0}</td>", row["Position"].ToString());
                if (type != "2" && type != "1")  
                sb.AppendFormat("<td name=\"EmpLevel\" title=\"{0}\">{0}</td>", row["EmpLevel"].ToString());
                if (type != "2" && type != "1")  
                sb.AppendFormat("<td name=\"Depart\" title=\"{0}\">{0}</td>", row["DepartName"].ToString());
                if (type != "2" && type != "1")  
                sb.AppendFormat("<td name=\"Business\" title=\"{0}\">{0}</td>", row["Business"].ToString());
                if (type != "2" && type != "1")  
                sb.AppendFormat("<td name=\"CompanyName\" title=\"{0}\">{0}</td>", row["CompanyName"].ToString());
                if (type != "2" && type != "1")  
                sb.AppendFormat("<td name=\"CityName\" title=\"{0}\">{0}</td>", row["CityName"].ToString());

                sb.AppendFormat("<td name=\"ComeDate\" title=\"{0}\">{0}</td>", row["ComeDate"].ToString());
                sb.AppendFormat("<td name=\"Sex\" title=\"{0}\">{0}</td>", row["Sex"].ToString());
                sb.AppendFormat("<td name=\"Education\" title=\"{0}\">{0}</td>", row["Education"].ToString());
                sb.AppendFormat("<td name=\"IDNo\" title=\"{0}\">{0}</td>", row["IDNo"].ToString());
                if (type != "1")
                sb.AppendFormat("<td name=\"BirthDay\" title=\"{0}\">{0}</td>", row["BirthDay"].ToString());
                if (type != "1")
                sb.AppendFormat("<td name=\"Age\" title=\"{0}\">{0}</td>", row["Age"].ToString());
                if (type != "2")
                sb.AppendFormat("<td name=\"Address\" title=\"{0}\">{0}</td>", row["Address"].ToString());
                if (type != "2" && type != "1")
                sb.AppendFormat("<td name=\"zip\" title=\"{0}\">{0}</td>", row["zip"].ToString());
                sb.AppendFormat("<td name=\"Mobile\" title=\"{0}\">{0}</td>", row["Mobile"].ToString());
                if (type != "2")
                sb.AppendFormat("<td name=\"HomeTel\" title=\"{0}\">{0}</td>", row["HomeTel"].ToString());
                if (type != "2")
                sb.AppendFormat("<td name=\"OfficeTel\" title=\"{0}\">{0}</td>", row["OfficeTel"].ToString());
                if (type != "2" && type != "1")
                sb.AppendFormat("<td name=\"FundCode\" title=\"{0}\">{0}</td>", row["FundCode"].ToString());
                if (type != "2")
                sb.AppendFormat("<td name=\"ConBegin\" title=\"{0}\">{0}</td>", row["ConBegin"].ToString());
                if (type != "2")
                sb.AppendFormat("<td name=\"ConEnd\" title=\"{0}\">{0}</td>", row["ConEnd"].ToString());
                if (type != "2")
                sb.AppendFormat("<td name=\"LeaveDate\" title=\"{0}\">{0}</td>", row["LeaveDate"].ToString());
                if (type != "2" && type != "1")  
                sb.AppendFormat("<td name=\"RoleName\" title=\"{0}\">{0}</td>", row["RoleName"].ToString());
                if (type != "2" && type != "1")  
                sb.AppendFormat("<td name=\"UpdateTime\" title=\"{0}\">{0}</td>", row["UpdateTime"].ToString());
                if (type != "2" && type != "1")  
                sb.AppendFormat("<td name=\"AddTime\" title=\"{0}\">{0}</td>", row["AddTime"].ToString());
                sb.AppendFormat("<td name=\"WorkRelation\" title=\"{0}\">{0}</td>", row["WorkRelation"].ToString());                
                sb.Append("</tr>");
            }
            sb.Append("</table>");
            return sb.ToString();
        }

        //*******************************************
        //功能概要       ：根据参数列表获得用户信息一览
        //参数説明       ：context 请求的上下文
        //返回值説明     ：无
        //功能詳細       ：根据参数列表获得用户信息一览
        //作成者         ：he.jifeng 
        //作成日         ：2010-03-05
        //*******************************************
        public string GetModelListByCoditions(System.Collections.Hashtable hsParams, out int count)
        {
            //order文
            string strOrder = "Hr_UserInfo.UserCode desc";
            if (hsParams.ContainsKey("sort"))
            {
                strOrder = "Hr_UserInfo." + hsParams["sort"].ToString();
            }
            //当前页数
            int intCurPage = 1;
            //显示行数
            int intRowCnt = 10;
            //where文
            string strWhere = getWhere(hsParams);


            //当前页数
            if (hsParams.ContainsKey("page"))
            {
                intCurPage = Convert.ToInt32(hsParams["page"]);
            }
            //显示行数
            if (hsParams.ContainsKey("rows"))
            {
                intRowCnt = Convert.ToInt32(hsParams["rows"]);
            }

            string showType = hsParams["show"].ToString();

            string FieldList = "";
            string TableFieldList = "";

            //简单模式
            if (showType == "1")
            {
                FieldList = "UserId,UserCode, UserName,BelongDepart,BelongCompanyName,Position,ComeDate, Sex, Education,IDNo,Mobile,HomeTel,OfficeTel,Address,Status,Validate,ConBegin,ConEnd,LeaveDate,WorkRelation";
                TableFieldList = "UserId,UserCode, UserName,BelongDepart,BelongCompanyName, Position,convert(char,ComeDate,23) AS ComeDate,CASE WHEN Sex='0' THEN '男' ELSE '女' END  AS Sex, Education,IDNo,Mobile,HomeTel,OfficeTel,Address,Status,Validate,convert(char,ConBegin,23) AS ConBegin,convert(char,ConEnd,23) AS ConEnd,convert(char,LeaveDate,23) AS LeaveDate,WorkRelation";
            }
            //生日模式
            else if (showType == "2")
            {
                FieldList = "UserId,UserCode, UserName,BelongDepart,BelongCompanyName,Sex,Age,BirthDay,Education,IDNo, ComeDate,Status,Validate,WorkRelation,Mobile";
                TableFieldList = "UserId,UserCode, UserName,BelongDepart,BelongCompanyName,CASE WHEN Sex='0' THEN '男' ELSE '女' END  AS Sex,DateDiff(year, BirthDay ,getdate()) AS Age, CASE WHEN BirthDay IS NULL THEN '' ELSE convert(char,BirthDay,23) END AS BirthDay,Education, IDNo, convert(char,ComeDate,23) AS ComeDate,Status,Validate,WorkRelation,Mobile";
            }
            //详细模式
            else if (showType == "3")
            {
                FieldList = "UserId,UserCode, UserName,BelongDepart,BelongBusiness,BelongCompanyName,BelongCityName,Position, EmpLevel,DepartName,Business,CompanyName,CityName,ComeDate,Sex,Education,IDNo,BirthDay,Age,Address,zip,Mobile,HomeTel,OfficeTel,FundCode,ConBegin, ConEnd, LeaveDate, RoleName,UpdateTime,AddTime,Status,Validate,WorkRelation";
                TableFieldList = "UserId,UserCode, UserName,BelongDepart,dbo.FN_GetBussinessByDepartID(BelongDepartId) as BelongBusiness,BelongCompanyName,BelongCityName,Position, EmpLevel,DepartName,dbo.FN_GetBussinessByDepartID(DepartId) as Business,CompanyName,CityName,convert(char,ComeDate,23) AS ComeDate,CASE WHEN Sex='0' THEN '男' ELSE '女' END  AS Sex,Education,IDNo,CASE WHEN BirthDay IS NULL THEN '' ELSE convert(char,BirthDay,23) END AS BirthDay,DateDiff(year, BirthDay ,getdate()) AS Age,Address,zip,Mobile,HomeTel,OfficeTel,FundCode,convert(char,ConBegin,23) AS ConBegin,convert(char,ConEnd,23) AS ConEnd,CASE WHEN LeaveDate IS NULL THEN '' ELSE convert(char,LeaveDate,23) END AS LeaveDate,dbo.FN_GetStrRoles(UserId) AS RoleName,convert(char,UpdateTime,23) AS UpdateTime,convert(char,AddTime,23) AS AddTime,Status,Validate,WorkRelation";
            }

            DataSet ds = Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetList(intCurPage, intRowCnt, strOrder, "Hr_UserInfo", strWhere, FieldList, TableFieldList, true);
            count = (int)ds.Tables[1].Rows[0][0];
            string str = GetHtml(ds, showType);

            return str;
        }

        //返回人事查询的表头
        public string GetHead(string showtype)
        {
            string str = "";
            if (showtype == "1")
            {
                str += "{a:{head:\"\",width:40},UserCode:{head:\"员工编号\",width:100,sortable:true},UserName:{head:\"员工姓名\",width:80,sortable:true},BelongDepart:{head:\"所属部门\",width:100,sortable:true},BelongCompanyName:{head:\"所属公司\",width:100,sortable:true},"
                    + "Position:{head:\"职务\",width:100,sortable:true},ComeDate:{head:\"入职时间\",width:100,sortable:true},Sex:{head:\"性别\",width:40,sortable:true},Education:{head:\"学历\",width:60,sortable:true},IDNo:{head:\"证件号\",width:150,sortable:true},"
                    + "Mobile:{head:\"手机\",width:100},HomeTel:{head:\"家庭电话\",width:80},OfficeTel:{head:\"办公电话\",width:80},Address:{head:\"联系地址\",width:200},ConBegin:{head:\"合同起始\",width:100,sortable:true},ConEnd:{head:\"合同终止\",width:100,sortable:true},LeaveDate:{head:\"离职日期\",width:100,sortable:true},WorkRelation:{head:\"劳动关系\",width:150,sortable:true},Status:{head:\"状态\",create:false}}";
            }
            else if (showtype == "2")
            {
                str += "{a:{head:\"\",width:40},UserCode:{head:\"员工编号\",width:100,sortable:true},UserName:{head:\"员工姓名\",width:80,sortable:true},BelongDepart:{head:\"所属部门\",width:100,sortable:true},BelongCompanyName:{head:\"所属公司\",width:100,sortable:true},"
                    + "Sex:{head:\"性别\",width:40,sortable:true},Mobile:{head:\"手机\",width:100},Age:{head:\"年龄\",width:40},BirthDay:{head:\"生日日期\",width:100,sortable:true},"
                    + "Education:{head:\"学历\",width:60},IDNo:{head:\"证件号\",width:150},ComeDate:{head:\"入职时间\",sortable:true,width:100},WorkRelation:{head:\"劳动关系\",width:150,sortable:true},Status:{head:\"状态\",create:false}}";
            }
            else if (showtype == "3")
            {
                str += "{a:{head:\"\",width:40},UserCode:{head:\"员工编号\",width:100,sortable:true},UserName:{head:\"员工姓名\",width:80,sortable:true},BelongDepart:{head:\"所属部门\",width:100,sortable:true},BelongBusiness:{head:\"所属商圈\",width:100},BelongCompanyName:{head:\"所属公司\",width:100,sortable:true},BelongCityName:{head:\"所属城市\",width:100,sortable:true},"
                    + "Position:{head:\"职务\",width:100,sortable:true},EmpLevel:{head:\"职级\",width:100,sortable:true},DepartName:{head:\"业务部门\",width:100,sortable:true},Business:{head:\"业务商圈\",width:100},CompanyName:{head:\"业务公司\",width:100,sortable:true},CityName:{head:\"业务城市\",width:100,sortable:true},"
                    + "ComeDate:{head:\"入职时间\",width:100,sortable:true},Sex:{head:\"性别\",width:40,sortable:true},Education:{head:\"学历\",width:60},IDNo:{head:\"证件号\",width:150},BirthDay:{head:\"生日日期\",width:100,sortable:true},Age:{head:\"年龄\",width:40},Address:{head:\"联系地址\",width:200},zip:{head:\"邮编\",width:60,sortable:true},"
                    + "Mobile:{head:\"手机\",width:100},HomeTel:{head:\"家庭电话\",width:80},OfficeTel:{head:\"办公电话\",width:80},FundCode:{head:\"公积金账号\",width:150},ConBegin:{head:\"合同起始\",width:120,sortable:true},ConEnd:{head:\"合同终止\",width:100,sortable:true},LeaveDate:{head:\"离职日期\",width:100,sortable:true},"
                    + "RoleName:{head:\"角色名\",width:200},UpdateTime:{head:\"更新日期\",width:100,sortable:true},AddTime:{head:\"建档日期\",width:100,sortable:true},WorkRelation:{head:\"劳动关系\",width:150,sortable:true},Status:{head:\"状态\",create:false}}";
            }

            return str;
        }


        //返回人事查询的HTML
        private string GetHtml(DataSet ds, string showtype)
        {
            string str = "";
            switch (showtype)
            {
                case "1":
                    str = ShowSimple(ds);
                    break;
                case "2":
                    str = ShowBirthday(ds);
                    break;
                case "3":
                    str = ShowDetail(ds);
                    break;
            }

            return str;
        }

        //简单显示的HTML
        private string ShowSimple(DataSet ds)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            //sb.Append("<table height=\"100%\" cellspacing=\"1\" class=\"tabsorternew\" id=\"report\" style=\"width:990px;\">");
            //sb.Append("<thead><tr>");
            //sb.Append("<th width=\"40px;\" ></th>");
            //sb.Append("<th width=\"80px;\" >员工编号</th>");
            //sb.Append("<th width=\"80px;\" >员工姓名</th>");
            //sb.Append("<th width=\"80px;\" >所属城市</th>");
            //sb.Append("<th width=\"80px;\" >所属公司</th>");
            //sb.Append("<th width=\"80px;\" >所属商圈</th>");
            //sb.Append("<th width=\"80px;\" >所属部门</th>");
            //sb.Append("<th width=\"80px;\" >手机</th>");
            //sb.Append("<th width=\"40px;\" >性别</th>");
            //sb.Append("<th width=\"60px;\" >学历</th>");
            //sb.Append("<th width=\"100px;\" >职务</th>");
            //sb.Append("<th width=\"120px;\" >入职时间</th>");
            //sb.Append("<th style=\"display:none;\">状态</th>");
            //sb.Append("</tr></thead><tbody>");

            foreach (System.Data.DataRow row in ds.Tables[0].Rows)
            {
                sb.AppendFormat("<dl id=\"{0}\" class=\"tr_houselist\">", row["UserId"].ToString());
                sb.AppendFormat("<dd><div class=\"{0}\" title=\"{1}\"></div><div class=\"{2}\" title=\"{3}\"></div></dd>", row["Validate"].ToString().ToLower() == "true" ? "activekey" : "noactivekey", row["Validate"].ToString().ToLower() == "true" ? "激活" : "冻结", row["Status"].ToString() == "1" ? "onjob" : "nojob", row["Status"].ToString() == "1" ? "在职" : "离职");
                sb.AppendFormat("<dd name=\"UserCode\" title=\"{0}\">{0}</dd>", row["UserCode"].ToString());
                sb.AppendFormat("<dd name=\"UserName\" title=\"{0}\">{0}</dd>", row["UserName"].ToString());
                sb.AppendFormat("<dd name=\"DepartName\" title=\"{0}\">{0}</dd>", row["BelongDepart"].ToString());
                sb.AppendFormat("<dd name=\"BelongCompanyName\" title=\"{0}\">{0}</dd>", row["BelongCompanyName"].ToString());
                sb.AppendFormat("<dd name=\"Position\" title=\"{0}\">{0}</dd>", row["Position"].ToString());
                sb.AppendFormat("<dd name=\"ComeDate\" title=\"{0}\">{0}</dd>", row["ComeDate"].ToString());
                sb.AppendFormat("<dd name=\"Sex\" title=\"{0}\">{0}</dd>", row["Sex"].ToString());
                sb.AppendFormat("<dd name=\"Education\" title=\"{0}\">{0}</dd>", row["Education"].ToString());
                sb.AppendFormat("<dd name=\"IDNo\" title=\"{0}\">{0}</dd>", row["IDNo"].ToString());
                sb.AppendFormat("<dd name=\"Mobile\" title=\"{0}\">{0}</dd>", row["Mobile"].ToString());
                sb.AppendFormat("<dd name=\"HomeTel\" title=\"{0}\">{0}</dd>", row["HomeTel"].ToString());
                sb.AppendFormat("<dd name=\"OfficeTel\" title=\"{0}\">{0}</dd>", row["OfficeTel"].ToString());
                sb.AppendFormat("<dd name=\"Address\" title=\"{0}\">{0}</dd>", row["Address"].ToString());
                sb.AppendFormat("<dd name=\"ConBegin\" title=\"{0}\">{0}</dd>", row["ConBegin"].ToString());
                sb.AppendFormat("<dd name=\"ConEnd\" title=\"{0}\">{0}</dd>", row["ConEnd"].ToString());
                sb.AppendFormat("<dd name=\"LeaveDate\" title=\"{0}\">{0}</dd>", row["LeaveDate"].ToString());
                sb.AppendFormat("<dd name=\"WorkRelation\" title=\"{0}\">{0}</dd>", row["WorkRelation"].ToString());
                sb.AppendFormat("<dd name=\"Status\" style=\"display:none;\">{0}</dd>", row["Status"].ToString());
                sb.Append("</dl>");
            }

            //sb.Append("</tbody></table>");

            return sb.ToString();
        }

        //生日显示的HTML
        private string ShowBirthday(DataSet ds)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            //sb.Append("<table height=\"100%\" cellspacing=\"1\" class=\"tabsorternew\" id=\"report\" style=\"width:1290px;\">");
            //sb.Append("<thead><tr>");
            //sb.Append("<th width=\"40px;\" ></th>");
            //sb.Append("<th width=\"80px;\">员工编号</th>");
            //sb.Append("<th width=\"80px;\">员工姓名</th>");
            //sb.Append("<th width=\"80px;\" >所属城市</th>");
            //sb.Append("<th width=\"80px;\" >所属公司</th>");
            //sb.Append("<th width=\"80px;\" >所属商圈</th>");
            //sb.Append("<th width=\"80px;\" >所属部门</th>");
            //sb.Append("<th width=\"80px;\" >手机</th>");
            //sb.Append("<th width=\"40px;\">性别</th>");
            //sb.Append("<th width=\"80px;\">生日日期</th>");
            //sb.Append("<th width=\"40px;\">年龄</th>");
            //sb.Append("<th width=\"60px;\">学历</th>");
            //sb.Append("<th width=\"150px;\">证件号</th>");
            //sb.Append("<th width=\"120px;\">入职日期</th>");
            //sb.Append("<th  style=\"display:none;\">状态</th>");
            //sb.Append("</tr></thead><tbody>");

            foreach (System.Data.DataRow row in ds.Tables[0].Rows)
            {
                sb.AppendFormat("<dl id=\"{0}\" class=\"tr_houselist\">", row["UserId"].ToString());
                sb.AppendFormat("<dd><div class=\"{0}\" title=\"{1}\"></div><div class=\"{2}\" title=\"{3}\"></div></dd>", row["Validate"].ToString().ToLower() == "true" ? "activekey" : "noactivekey", row["Validate"].ToString().ToLower() == "true" ? "激活" : "冻结", row["Status"].ToString() == "1" ? "onjob" : "nojob", row["Status"].ToString() == "1" ? "在职" : "离职");
                sb.AppendFormat("<dd name=\"UserCode\" title=\"{0}\">{0}</dd>", row["UserCode"].ToString());
                sb.AppendFormat("<dd name=\"UserName\" title=\"{0}\">{0}</dd>", row["UserName"].ToString());
                sb.AppendFormat("<dd name=\"DepartName\" title=\"{0}\">{0}</dd>", row["BelongDepart"].ToString());
                sb.AppendFormat("<dd name=\"BelongCompanyName\" title=\"{0}\">{0}</dd>", row["BelongCompanyName"].ToString());
                sb.AppendFormat("<dd name=\"Sex\" title=\"{0}\">{0}</dd>", row["Sex"].ToString());
                sb.AppendFormat("<dd name=\"Mobile\" title=\"{0}\">{0}</dd>", row["Mobile"].ToString());
                sb.AppendFormat("<dd name=\"Age\" v>{0}</dd>", row["Age"].ToString());
                sb.AppendFormat("<dd name=\"BirthDay\" title=\"{0}\">{0}</dd>", row["BirthDay"].ToString());
                sb.AppendFormat("<dd name=\"Education\" title=\"{0}\">{0}</dd>", row["Education"].ToString());
                sb.AppendFormat("<dd name=\"IDNo\" title=\"{0}\">{0}</dd>", row["IDNo"].ToString());
                sb.AppendFormat("<dd name=\"ComeDate\" title=\"{0}\">{0}</dd>", row["ComeDate"].ToString());
                sb.AppendFormat("<dd name=\"WorkRelation\" title=\"{0}\">{0}</dd>", row["WorkRelation"].ToString());
                sb.AppendFormat("<dd name=\"Status\" style=\"display:none;\">{0}</dd>", row["Status"].ToString());
                sb.Append("</dl>");
            }

            //sb.Append("</tbody></table>");

            return sb.ToString();
        }

        //详细显示的HTML
        private string ShowDetail(DataSet ds)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            foreach (System.Data.DataRow row in ds.Tables[0].Rows)
            {
                sb.AppendFormat("<dl id=\"{0}\" class=\"tr_houselist\">", row["UserId"].ToString());
                sb.AppendFormat("<dd><div class=\"{0}\" title=\"{1}\"></div><div class=\"{2}\" title=\"{3}\"></div></td>", row["Validate"].ToString().ToLower() == "true" ? "activekey" : "noactivekey", row["Validate"].ToString().ToLower() == "true" ? "激活" : "冻结", row["Status"].ToString() == "1" ? "onjob" : "nojob", row["Status"].ToString() == "1" ? "在职" : "离职");
                sb.AppendFormat("<dd name=\"UserCode\" title=\"{0}\">{0}</dd>", row["UserCode"].ToString());
                sb.AppendFormat("<dd name=\"UserName\" title=\"{0}\">{0}</dd>", row["UserName"].ToString());
                sb.AppendFormat("<dd name=\"DepartName\" title=\"{0}\">{0}</dd>", row["BelongDepart"].ToString());
                sb.AppendFormat("<dd name=\"BelongBusiness\" title=\"{0}\">{0}</dd>", row["BelongBusiness"].ToString());
                sb.AppendFormat("<dd name=\"BelongCompanyName\" title=\"{0}\">{0}</dd>", row["BelongCompanyName"].ToString());
                sb.AppendFormat("<dd name=\"BelongCityName\" title=\"{0}\">{0}</dd>", row["BelongCityName"].ToString());
                sb.AppendFormat("<dd name=\"Position\" title=\"{0}\">{0}</dd>", row["Position"].ToString());
                sb.AppendFormat("<dd name=\"EmpLevel\" title=\"{0}\">{0}</dd>", row["EmpLevel"].ToString());
                sb.AppendFormat("<dd name=\"Depart\" title=\"{0}\">{0}</dd>", row["DepartName"].ToString());
                sb.AppendFormat("<dd name=\"Business\" title=\"{0}\">{0}</dd>", row["Business"].ToString());
                sb.AppendFormat("<dd name=\"CompanyName\" title=\"{0}\">{0}</dd>", row["CompanyName"].ToString());                
                sb.AppendFormat("<dd name=\"CityName\" title=\"{0}\">{0}</dd>", row["CityName"].ToString());
                sb.AppendFormat("<dd name=\"ComeDate\" title=\"{0}\">{0}</dd>", row["ComeDate"].ToString());
                sb.AppendFormat("<dd name=\"Sex\" title=\"{0}\">{0}</dd>", row["Sex"].ToString());
                sb.AppendFormat("<dd name=\"Education\" title=\"{0}\">{0}</dd>", row["Education"].ToString());
                sb.AppendFormat("<dd name=\"IDNo\" title=\"{0}\">{0}</dd>", row["IDNo"].ToString());
                sb.AppendFormat("<dd name=\"BirthDay\" title=\"{0}\">{0}</dd>", row["BirthDay"].ToString());
                sb.AppendFormat("<dd name=\"Age\" title=\"{0}\">{0}</dd>", row["Age"].ToString());
                sb.AppendFormat("<dd name=\"Address\" title=\"{0}\">{0}</dd>", row["Address"].ToString());
                sb.AppendFormat("<dd name=\"zip\" title=\"{0}\">{0}</dd>", row["zip"].ToString());
                sb.AppendFormat("<dd name=\"Mobile\" title=\"{0}\">{0}</dd>", row["Mobile"].ToString());
                sb.AppendFormat("<dd name=\"HomeTel\" title=\"{0}\">{0}</dd>", row["HomeTel"].ToString());
                sb.AppendFormat("<dd name=\"OfficeTel\" title=\"{0}\">{0}</dd>", row["OfficeTel"].ToString());
                sb.AppendFormat("<dd name=\"FundCode\" title=\"{0}\">{0}</dd>", row["FundCode"].ToString());
                sb.AppendFormat("<dd name=\"ConBegin\" title=\"{0}\">{0}</dd>", row["ConBegin"].ToString());
                sb.AppendFormat("<dd name=\"ConEnd\" title=\"{0}\">{0}</dd>", row["ConEnd"].ToString());
                sb.AppendFormat("<dd name=\"LeaveDate\" title=\"{0}\">{0}</dd>", row["LeaveDate"].ToString());                
                sb.AppendFormat("<dd name=\"RoleName\" title=\"{0}\">{0}</dd>", row["RoleName"].ToString());
                sb.AppendFormat("<dd name=\"UpdateTime\" title=\"{0}\">{0}</dd>", row["UpdateTime"].ToString());
                sb.AppendFormat("<dd name=\"AddTime\" title=\"{0}\">{0}</dd>", row["AddTime"].ToString());
                sb.AppendFormat("<dd name=\"WorkRelation\" title=\"{0}\">{0}</dd>", row["WorkRelation"].ToString());
                sb.AppendFormat("<dd name=\"Status\" style=\"display:none;\">{0}</dd>", row["Status"].ToString());
                sb.Append("</dl>");
            }

            //sb.Append("</tbody></table>");

            return sb.ToString();
        }

        //*******************************************
        //功能概要       ：根据参数列表获得Where文
        //参数説明       ：hsParams 参数列表
        //返回值説明     ：where文
        //功能詳細       ：根据参数列表获得Where文
        //作成者         ：he.jifeng 
        //作成日         ：2010-03-07
        //*******************************************
        public string getWhere(System.Collections.Hashtable hsParams)
        {
            string strWhere = " 1=1 ";
            //权限
            string strPermit;

            //权限
            if (hsParams.ContainsKey("Permit"))
            {
                strPermit = hsParams["Permit"].ToString();
                if (strPermit == Constants.Permit_ViewAllHrUserInfo)
                {
                    //全部
                }
                else if (strPermit == Constants.Permit_ViewCityHrUserInfo)
                {
                    strWhere += string.Format(" And BelongCityId = '{0}'", hsParams["CurCityId"]);
                }
                else if (strPermit == Constants.Permit_ViewCompanyHrUserInfo)
                {
                    strWhere += string.Format(" And BelongCompanyId= '{0}'", hsParams["CurCompanyId"]);
                }
                else if (strPermit == Constants.Permit_ViewDepartHrUserInfo)
                {
                    strWhere += " And EXISTS(";
                    strWhere += string.Format("Select 1 from Struct_UserDepartRelation M WHERE Hr_UserInfo.BelongDepartId=M.DepartId And M.Userid= '{0}' and ViewHrInfo=1", hsParams["CurUserId"]);
                    strWhere += ") ";
                }
            }
            //权限为当前用户
            else if (hsParams.ContainsKey("CurUserId"))
            {
                strWhere += " And UserId = '" + hsParams["CurUserId"] + "' and (select count(*) from Struct_UserDepartRelation where UserId='" + hsParams["CurUserId"] + "' and IsBelong=1 and ViewHrInfo=1)>0";
            }

            //员工编号
            if (hsParams.ContainsKey("UserId"))
            {
                strWhere = strWhere + " And UserId = '" + hsParams["UserId"].ToString() + "' ";
            }
            //部门编号
            if (hsParams.ContainsKey("DepartId"))
            {
                strWhere = strWhere + " And BelongDepartId = '" + hsParams["DepartId"].ToString() + "' ";
            }


            if (hsParams["userid_s"].ToString() != Guid.Empty.ToString())
                strWhere = strWhere + " AND (UserId = '" + hsParams["userid_s"].ToString() + "') ";
            else if (hsParams["departid_s"].ToString() != Guid.Empty.ToString())
                strWhere = strWhere + " AND (BelongDepartId = '" + hsParams["departid_s"].ToString() + "')";
            else if (hsParams["areaid_s"].ToString() != Guid.Empty.ToString())
            {
                Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo item = null;
                string strCachkey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_DEPARTMENT, hsParams["areaid_s"].ToString());
                Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
                item = cs.GetObject<Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo>(strCachkey);
                if (!cs.Hit)
                {
                    item = Chenxin.Lib.Hr.DAL.Hr_DepartmentInfo.GetModel(new Guid(hsParams["areaid_s"].ToString()));
                    if (item != null) cs.Set(strCachkey, item, DateTime.Now.AddDays(1));
                }

                if (item == null) return string.Format("{{success:'0',msg:'{0}',data:''}}", "获取商圈或分类数据丢失");

                strWhere = strWhere + " AND (BelongDepartId in (select departId from Hr_DepartmentInfo where DepartSrc like '" + item.DepartSrc + "%'))";
            }
            else if (hsParams["companyid_s"].ToString() != Guid.Empty.ToString())
                strWhere = strWhere + " AND BelongCompanyId = '" + hsParams["companyid_s"].ToString() + "'";
            else if (hsParams["cityid_s"].ToString() != Guid.Empty.ToString())
                strWhere = strWhere + " AND BelongCityId = '" + hsParams["cityid_s"].ToString() + "'";

            //状态
            if (hsParams.ContainsKey("Status"))
            {
                strWhere = strWhere + " And Status = " + hsParams["Status"].ToString();
            }
            //到职时间（开始）
            if (hsParams.ContainsKey("ComeDateFrom"))
            {
                strWhere = strWhere + " And ComeDate >= cast('" + hsParams["ComeDateFrom"].ToString() + "'as datetime)";
            }
            //到职时间（结束）
            if (hsParams.ContainsKey("ComeDateTo"))
            {
                strWhere = strWhere + " And ComeDate <= cast('" + hsParams["ComeDateTo"].ToString() + "'as datetime)";
            }
            //合同时间（开始）
            if (hsParams.ContainsKey("ContractDateFrom"))
            {
                strWhere = strWhere + " And ConBegin >= cast('" + hsParams["ContractDateFrom"].ToString() + "'as datetime)";
            }
            //合同时间（结束）
            if (hsParams.ContainsKey("ContractDateTo"))
            {
                strWhere = strWhere + " And ConBegin <= cast('" + hsParams["ContractDateTo"].ToString() + "'as datetime)";
            }
            //离职时间（开始）
            if (hsParams.ContainsKey("LeaveDateFrom"))
            {
                strWhere = strWhere + " And LeaveDate >= cast('" + hsParams["LeaveDateFrom"].ToString() + "'as datetime)";
            }
            //离职时间（结束）
            if (hsParams.ContainsKey("LeaveDateTo"))
            {
                strWhere = strWhere + " And LeaveDate <= cast('" + hsParams["LeaveDateTo"].ToString() + "'as datetime)";
            }
            //身份证号
            if (hsParams.ContainsKey("IDNo"))
            {
                strWhere = strWhere + " And IDNo like'%" + hsParams["IDNo"].ToString() + "%' ";
            }
            //角色
            if (hsParams.ContainsKey("RoleId"))
            {
                strWhere = strWhere + " And exists(select 1 from Base_RoleUserRelationInfo R where Hr_UserInfo.UserId = R.UserId and R.RoleId = '" + hsParams["RoleId"].ToString() + "')";
            }
            //职务
            if (hsParams.ContainsKey("Position"))
            {
                strWhere = strWhere + " And Position = '" + hsParams["Position"].ToString() + "' ";
            }
            //虚账号
            if (hsParams.ContainsKey("IsVirtual"))
            {
                strWhere = strWhere + " and IsVirtual ='" + hsParams["IsVirtual"].ToString().Trim() + "'";
            }
            else
            {
                strWhere = strWhere + " and IsVirtual ='false'";
            }
            //工号
            if (hsParams.ContainsKey("divBirthday"))
            {
                strWhere = strWhere + " And month(BirthDay) = '" + hsParams["divBirthday"].ToString() + "' ";
            }
            //公积金
            if (hsParams.ContainsKey("FundCode"))
            {
                strWhere = strWhere + " And FundCode like '%" + hsParams["FundCode"].ToString() + "%' ";
            }
            //手机
            if (hsParams.ContainsKey("Mobile"))
            {
                strWhere = strWhere + " And Mobile like '%" + hsParams["Mobile"].ToString() + "%' ";
            }
            //家庭电话
            if (hsParams.ContainsKey("HomeTel"))
            {
                strWhere = strWhere + " And HomeTel like '%" + hsParams["HomeTel"].ToString() + "%' ";
            }
            //办公电话
            if (hsParams.ContainsKey("OfficeTel"))
            {
                strWhere = strWhere + " And OfficeTel like '%" + hsParams["OfficeTel"].ToString() + "%' ";
            }
            //智能
            if (hsParams.ContainsKey("keyword"))
            {
                strWhere = strWhere + string.Format(" And (UserCode like '%{0}%' or UserName like '%{0}%' or BelongDepart like '%{0}%') ", hsParams["keyword"].ToString());
            }
            //快捷方式
            if (hsParams.ContainsKey("quicktype"))
            {
                switch (hsParams["quicktype"].ToString())
                {
                    case "ConEndCall":
                        strWhere = strWhere + " And (datediff(d,ConEnd,'" + DateTime.Now + "')<30)";
                        break;
                }
            }


            return strWhere;
        }

        /// <summary>
        /// 通过UserId得到一个对象实体
        /// </summary>
        public ArrayList GetUsersDeparts(string strParam)
        {
            ArrayList lsUsersDeparts = new ArrayList();

            string strWhereUser;
            string strWhereDepart;

            strWhereUser = " (UserName like '%" + strParam + "%') OR (Upper(UserCode) like '%" + strParam.ToUpper() + "%') ";
            strWhereDepart = " DepartName like '%" + strParam + "%' and (DepartProperty=500 or DepartProperty=600) ";

            List<Chenxin.Lib.Passport.Entity.Hr_UserInfo> lsUserInfo = Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetListArray(strWhereUser);
            List<Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo> lsDepartInfo = Chenxin.Lib.Hr.DAL.Hr_DepartmentInfo.GetListArray(strWhereDepart);

            lsUsersDeparts.Add(lsUserInfo);
            lsUsersDeparts.Add(lsDepartInfo);

            return lsUsersDeparts;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetListByDepartId(System.Collections.Hashtable hsParams)
        {
            string strWhere = "";
            //order文
            string strOrder = "";
            //当前页数
            int intCurPage = 1;
            //显示行数
            int intRowCnt = 10;
            //select文
            string strSelect;

            //排序项目
            if (hsParams.ContainsKey("DepartId"))
            {
                strWhere = " BelongDepartId = '" + hsParams["DepartId"].ToString() + "'";
            }
            else
            {
                strWhere = "1=1";
            }

            //排序项目
            if (hsParams.ContainsKey("sidx"))
            {
                strOrder = strOrder + hsParams["sidx"].ToString();
            }

            //排序方式
            if (hsParams.ContainsKey("sord"))
            {
                strOrder = strOrder + " " + hsParams["sord"].ToString();
            }

            //当前页数
            if (hsParams.ContainsKey("page"))
            {
                intCurPage = Convert.ToInt32(hsParams["page"]);
            }
            //显示行数
            if (hsParams.ContainsKey("rows"))
            {
                intRowCnt = Convert.ToInt32(hsParams["rows"]);
            }

            strSelect = " UserId,UserCode,UserName,CASE WHEN Sex='0' THEN '男' ELSE '女' END  AS Sex,CASE WHEN BirthDay IS NULL THEN '' ELSE convert(char,BirthDay,23) END AS BirthDay,convert(char,ComeDate,23) AS ComeDate";

            DataSet ds = Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetList(strSelect, strWhere, strOrder, intCurPage, intRowCnt);

            return ds;
        }

        //密码重置
        public void ResetPassword(Guid gdUserId, string newpwd)
        {
            Chenxin.Lib.Passport.DAL.Hr_UserInfo.resetPassword(gdUserId, newpwd);
        }


        /// <summary>
        /// 根据权限获得用户数据
        /// </summary>
        /// <param name="htParams">参数列表</param>
        /// <returns></returns>
        public DataSet GetListByPermit(Hashtable htParams)
        {
            System.Text.StringBuilder strWhere = new System.Text.StringBuilder();
            strWhere.Append(" 1=1 ");
            //权限
            string strPermit;

            //权限
            if (htParams.ContainsKey("Permit"))
            {
                strPermit = htParams["Permit"].ToString();
                if (strPermit == Constants.Permit_ViewAllVacation)
                {
                    //全部
                }
                else if (strPermit == Constants.Permit_ViewCityVacation)
                {
                    strWhere.AppendFormat(" And CityId = '{0}'", htParams["CurCityId"]);
                }
                else if (strPermit == Constants.Permit_ViewCompanyVacation)
                {
                    strWhere.AppendFormat(" And CompanyId= '{0}'", htParams["CurCompanyId"]);
                }
                else if (strPermit == Constants.Permit_ViewDepartVacation)
                {
                    strWhere.Append(" And EXISTS(");
                    strWhere.AppendFormat("Select 1 from Struct_UserDepartRelation M WHERE Hr_UserInfo.DepartId=M.DepartId And M.Userid= '{0}'", htParams["CurUserId"]);
                    strWhere.Append(") ");
                }
            }
            //权限为当前用户
            else if (htParams.ContainsKey("CurUserId"))
            {
                strWhere.Append(" And UserId = '" + htParams["CurUserId"] + "'");
            }

            DataSet ds = Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetList(strWhere.ToString());
            return ds;
        }

        /// <summary>
        /// 获得个人通讯录
        /// </summary>
        /// <param name="htParams">检索条件</param>
        /// <returns>人事通讯录</returns>
        public DataSet GetPersonnelListByConditions(Hashtable htParams)
        {
            System.Text.StringBuilder strWhere = new System.Text.StringBuilder();
            string OrderField = "DepartName, UserName ASC";
            string FieldList = "UserId,UserName,UserCode,DepartName,Position,Mobile,HomeTel,EMail";
            string TableFieldList = "UserId,UserName,UserCode,DepartName,Position,Mobile,HomeTel,EMail";
            string TableName = "Hr_UserInfo";
            int PageIndex = 1;
            int PageSize = 10;

            //string StrWhere = " 1=1 ";
            strWhere.Append(" IsVirtual=0 ");
            strWhere.Append(" And Status = 1 ");
            strWhere.Append(" And Validate = 1 ");

            //权限
            string strPermit;

            //权限
            if (htParams.ContainsKey("Permit"))
            {
                strPermit = htParams["Permit"].ToString();
                if (strPermit == Constants.Permit_ViewAllContacts)
                {
                    //全部
                }
                else if (strPermit == Constants.Permit_ViewCityContacts)
                {
                    strWhere.AppendFormat(" And CityId = '{0}'", htParams["CurCityId"]);
                }
                else if (strPermit == Constants.Permit_ViewCompanyContacts)
                {
                    strWhere.AppendFormat(" And CompanyId= '{0}'", htParams["CurCompanyId"]);
                }
                else if (strPermit == Constants.Permit_ViewDepartContacts)
                {
                    strWhere.Append(" And EXISTS(");
                    strWhere.AppendFormat("Select 1 from Struct_UserDepartRelation M WHERE Hr_UserInfo.BelongDepartId=M.DepartId And M.Userid= '{0}' And M.ViewHrInfo=1 ", htParams["CurUserId"]);
                    strWhere.Append(") ");
                }
            }
            //权限为当前用户
            else if (htParams.ContainsKey("CurUserId"))
            {
                strWhere.Append(" And UserId = '" + htParams["CurUserId"] + "'");
            }

            //首字母
            if (htParams.ContainsKey("Initial"))
            {
                strWhere.Append(" And Initial='" + htParams["Initial"] + "'");
            }

            if (htParams.ContainsKey("pageIndex"))
            {
                PageIndex = Convert.ToInt32(htParams["pageIndex"]);
            }
            if (htParams.ContainsKey("pageSize"))
            {
                PageSize = Convert.ToInt32(htParams["pageSize"]);
            }

            //用户名
            if (htParams.ContainsKey("UserId"))
            {
                strWhere.Append(" And UserId = '" + htParams["UserId"] + "'");
            }
            //部门
            else if (htParams.ContainsKey("DepartId"))
            {
                strWhere.Append(" And DepartId = '" + htParams["DepartId"] + "'");
            }
            //商圈
            else if (htParams.ContainsKey("AreaId"))
            {
                Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo entArea = null;
                string strCachkey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_DEPARTMENT, htParams["AreaId"]);
                Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);

                entArea = cs.GetObject<Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo>(strCachkey);
                if (!cs.Hit)
                {
                    entArea = Chenxin.Lib.Hr.DAL.Hr_DepartmentInfo.GetModel(new Guid(htParams["AreaId"].ToString()));
                    if (entArea != null) cs.Set(strCachkey, entArea, DateTime.Now.AddDays(1));
                }

                if (entArea != null)
                {
                    strWhere.AppendFormat(" AND (DepartId in (select departId from Hr_DepartmentInfo where DepartSrc like '{0}%'))", entArea.DepartSrc);
                }
            }
            //公司
            else if (htParams.ContainsKey("CompanyId"))
            {
                strWhere.AppendFormat(" AND CompanyId = '{0}' ", htParams["CompanyId"]);
            }
            //城市
            else if (htParams.ContainsKey("CityId"))
            {
                strWhere.AppendFormat(" AND CityId = '{0}' ", htParams["CityId"]);
            }

            //根据sql执行查询
            DataSet ds = Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetList(PageIndex, PageSize, OrderField, TableName, strWhere.ToString(), FieldList, TableFieldList, true);

            return ds;
        }



        public string CheckChange(Chenxin.Lib.Passport.Entity.Hr_UserInfo olduserinfo, Chenxin.Lib.Passport.Entity.Hr_UserInfo newuserinfo)
        {
            string str = "";

            //姓名
            if (!strEqual(olduserinfo.UserName, newuserinfo.UserName))
                str += string.Format("姓名由：{0} 变为 {1},", olduserinfo.UserName, newuserinfo.UserName);
            //性别
            if (!strEqual(olduserinfo.Sex.ToString(), newuserinfo.Sex.ToString()))
                str += string.Format("性别由：{0} 变为 {1},", olduserinfo.Sex.ToString() == "0" ? "男" : "女", newuserinfo.Sex.ToString() == "0" ? "男" : "女");
            //学历
            if (!strEqual(olduserinfo.Education, newuserinfo.Education))
                str += string.Format("学历由：{0} 变为 {1},", olduserinfo.Education, newuserinfo.Education);
            //证件类型
            if (!strEqual(olduserinfo.IDType, newuserinfo.IDType))
                str += string.Format("证件类型由：{0} 变为 {1},", olduserinfo.IDType, newuserinfo.IDType);
            //证件号
            if (!strEqual(olduserinfo.IDNo, newuserinfo.IDNo))
                str += string.Format("证件号由：{0} 变为 {1},", olduserinfo.IDNo, newuserinfo.IDNo);
            //生日
            if (!strEqual(olduserinfo.BirthDay.ToString(), newuserinfo.BirthDay.ToString()))
                str += string.Format("生日由：{0} 变为 {1},", olduserinfo.BirthDay.ToString(), newuserinfo.BirthDay.ToString());
            //地址
            if (!strEqual(olduserinfo.Address, newuserinfo.Address))
                str += string.Format("地址由：{0} 变为 {1},", olduserinfo.Address, newuserinfo.Address);
            //手机
            if (!strEqual(olduserinfo.Mobile, newuserinfo.Mobile))
                str += string.Format("手机由：{0} 变为 {1},", olduserinfo.Mobile, newuserinfo.Mobile);
            //家庭电话
            if (!strEqual(olduserinfo.HomeTel, newuserinfo.HomeTel))
                str += string.Format("家庭电话由：{0} 变为 {1},", olduserinfo.HomeTel, newuserinfo.HomeTel);
            //办公电话
            if (!strEqual(olduserinfo.OfficeTel, newuserinfo.OfficeTel))
                str += string.Format("办公电话由：{0} 变为 {1},", olduserinfo.OfficeTel, newuserinfo.OfficeTel);
            //工资账号
            if (!strEqual(olduserinfo.BankNo, newuserinfo.BankNo))
                str += string.Format("工资账号由：{0} 变为 {1},", olduserinfo.BankNo, newuserinfo.BankNo);
            //合同起始日
            if (!strEqual(olduserinfo.ConBegin.ToString(), newuserinfo.ConBegin.ToString()))
                str += string.Format("合同起始日由：{0} 变为 {1},", olduserinfo.ConBegin.ToString(), newuserinfo.ConBegin.ToString());
            //合同终止日
            if (!strEqual(olduserinfo.ConEnd.ToString(), newuserinfo.ConEnd.ToString()))
                str += string.Format("合同终止日由：{0} 变为 {1},", olduserinfo.ConEnd.ToString(), newuserinfo.ConEnd.ToString());
            //职务
            if (!strEqual(olduserinfo.Position, newuserinfo.Position))
                str += string.Format("职务由：{0} 变为 {1},", olduserinfo.Position, newuserinfo.Position);
            //职级
            if (!strEqual(olduserinfo.EmpLevel, newuserinfo.EmpLevel))
                str += string.Format("职级由：{0} 变为 {1},", olduserinfo.EmpLevel, newuserinfo.EmpLevel);
            //公积金账号
            if (!strEqual(olduserinfo.FundCode, newuserinfo.FundCode))
                str += string.Format("公积金账号由：{0} 变为 {1},", olduserinfo.FundCode, newuserinfo.FundCode);
            //备注
            if (!strEqual(olduserinfo.Remark, newuserinfo.Remark))
                str += string.Format("备注由：{0} 变为 {1},", olduserinfo.Remark, newuserinfo.Remark);
            //工龄起始日
            if (!strEqual(olduserinfo.WorkAgeBegin.ToString(), newuserinfo.WorkAgeBegin.ToString()))
                str += string.Format("工龄起始日由：{0} 变为 {1},", olduserinfo.WorkAgeBegin.ToString(), newuserinfo.WorkAgeBegin.ToString());
            //所属城市
            if (!strEqual(olduserinfo.BelongCityName, newuserinfo.BelongCityName))
                str += string.Format("所属城市由：{0} 变为 {1},", olduserinfo.BelongCityName, newuserinfo.BelongCityName);
            //所属公司
            if (!strEqual(olduserinfo.BelongCompanyName, newuserinfo.BelongCompanyName))
                str += string.Format("所属公司由：{0} 变为 {1},", olduserinfo.BelongCompanyName, newuserinfo.BelongCompanyName);
            //所属部门
            if (!strEqual(olduserinfo.BelongDepart, newuserinfo.BelongDepart))
                str += string.Format("所属部门由：{0} 变为 {1},", olduserinfo.BelongDepart, newuserinfo.BelongDepart);
            //邮箱
            if (!strEqual(olduserinfo.Email, newuserinfo.Email))
                str += string.Format("邮箱由：{0} 变为 {1},", olduserinfo.Email, newuserinfo.Email);
            //邮编
            if (!strEqual(olduserinfo.Zip, newuserinfo.Zip))
                str += string.Format("邮编由：{0} 变为 {1},", olduserinfo.Zip, newuserinfo.Zip);
            //劳动关系
            if (!strEqual(olduserinfo.WorkRelation, newuserinfo.WorkRelation))
                str += string.Format("劳动关系由：{0} 变为 {1},", olduserinfo.WorkRelation, newuserinfo.WorkRelation);
            if (str.Length > 0)
                str = str.Remove(str.Length - 1, 1);
            return str;
        }

        private static bool strEqual(string str1, string str2)
        {
            if (str1 == null)
            {
                str1 = "";
            }

            if (str2 == null)
            {
                str2 = "";
            }

            return str1.Equals(str2);
        }

        #endregion  成员方法
    }
}

